package com.motherchild.admin.service.impl;

import com.motherchild.admin.dto.LoginDTO;
import com.motherchild.admin.mapper.LoginMapper;
import com.motherchild.admin.service.LoginService;
import com.motherchild.admin.vo.LoginVO;
import com.motherchild.common.ApiResponse;
import com.motherchild.common.exception.BusinessException;
import com.motherchild.user.dto.Employee;
import com.motherchild.user.dto.User;
import com.mysql.cj.util.StringUtils;
import com.motherchild.common.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author zhuchenxu
 * @create 2025-02-12-10:23
 */
@Service
public class LoginServiceImpl implements LoginService {
    @Autowired
    private LoginMapper loginMapper;

    @Override
    public Integer login(LoginDTO loginDTO) {
        String password = loginMapper.selectByUsername(loginDTO.getUsername());
        System.out.println("password = " + password);
        if (password.equals(loginDTO.getPassword())) {
            return 0;
        }
        return 1;
    }

    @Override
    public Employee fetchUserRole(LoginDTO loginDTO) {
        Employee user = loginMapper.fetchUserRole(loginDTO.getUsername());
        return user;
    }
}
